﻿/***************************************************************
 * 开发人员：网魂小兵@http://www.mozlite.com
 * 
 * 缓存实例。
 * 
 * 最后修改：2011-10-28
 * ************************************************************/
namespace Mozlite.Caching
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Web.Caching;
    using System.Threading;

    internal class CacheEntry
    {
        private object internalLocker;
        private readonly object locker = new object();

        internal CacheEntry()
        {
            this.LastUpdate = DateTime.MinValue;
            this.LastUse = DateTime.MinValue;
            this.CreateDateTime = DateTime.UtcNow;
            this.CacheItemPriority = CacheItemPriority.Normal;
        }

        public CacheItemPriority CacheItemPriority { get; set; }

        public CacheLoaderDelegate CacheLoader { get; set; }

        public DateTime CreateDateTime { get; private set; }

        public object InternalLocker
        {
            get
            {
                if (this.internalLocker == null)
                {
                    Interlocked.CompareExchange(ref this.internalLocker, new object(), null);
                }
                return this.internalLocker;
            }
        }

        public DateTime LastUpdate
        {
            get;
            set;
        }

        public DateTime LastUse
        {
            get;
            set;
        }

        public object Locker
        {
            get
            {
                return this.locker;
            }
        }

        public TimeSpan RefreshInterval
        {
            get;
            set;
        }

        public TimeSpan SlidingExpiration
        {
            get;
            set;
        }
    }
}
